package my.jieh.tips.util.jar;

import java.io.*;
import java.util.*;
import java.util.jar.*;

/**
 * <p>Title: Core Java Technologies Tech Tips</p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: Blueimp</p>
 * @author jieh
 * @version 1.0
 */

public class JarDir {
  public static void main(String args[]) throws IOException {
    /*
    if (args.length != 1) {
      System.out.println("Please provide a JAR filename");
      System.exit( -1);
    }
    JarFile jarFile = new JarFile(args[0]);
    */
    JarFile jarFile = new JarFile("Java2Demo.jar");
    Enumeration eum = jarFile.entries();
    while (eum.hasMoreElements()) {
      process(eum.nextElement());
    }
  }

  private static void process(Object obj) {
    JarEntry entry = (JarEntry) obj;
    String name = entry.getName();
    long size = entry.getSize();
    long compressedSize = entry.getCompressedSize();
    System.out.println(name + "\t" + size + "\t" + compressedSize);
  }
}
